#define _CRT_SECURE_NO_WARNINGS 1

#include <iostream>
using namespace std;

class Date 
{
public:
    int GetMonthDay(int year, int month)
    {
        static int days[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
        if (month == 2 && (year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
        {
            days[2] = 29;
        }
        return days[month];
    }

    void GetDate(Date& n)
    {
        n.day += n.x;
        while (n.day > GetMonthDay(n.year, n.month))
        {
            n.day -= GetMonthDay(n.year, n.month);
            n.month++;
            if (n.month > 12)
            {
                n.year++;
                n.month = 1;
            }
        }
    }


    int year;
    int month;
    int day;
    int x;
};

int main() {
    int n = 2;
    //cin >> n;
    Date d[2];
    for (int i = 0; i < n; i++)
    {
        cin >> d[i].year >> d[i].month >> d[i].day >> d[i].x;
        d->GetDate(d[i]);
        printf("%04d-%02d-%02d\n", d[i].year, d[i].month, d[i].day);
    }
}



#if 0
#include <iostream>
using namespace std;

struct Date {
    int year;
    int month;
    int day;
    int x;
};

int GetMonthDay(int year, int month)
{
    static int days[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
    if (month == 2 && (year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
    {
        days[2] = 29;
    }
    return days[month];
}

void GetDate(Date& n)
{
    n.day += n.x;
    while (n.day > GetMonthDay(n.year, n.month))
    {
        n.day -= GetMonthDay(n.year, n.month);
        n.month++;
        if (n.month > 12)
        {
            n.year++;
            n.month = 1;
        }
    }
}


int main() {
    int n = 0;
    //cin >> n;
    Date d[1];
    for (int i = 0; i < n; i++)
    {
        cin >> d[i].year >> d[i].month >> d[i].day >> d[i].x;
        GetDate(d[i]);
        printf("%04d-%02d-%02d\n", d[i].year, d[i].month, d[i].day);
    }
}
#endif
